package com.nbicc.newsattachments.controller;

import com.nbicc.common.RequestPageObj;
import com.nbicc.common.ResponseObj;
import com.nbicc.newsattachments.po.NewsAttachments;
import com.nbicc.newsattachments.service.INewsAttachmentsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import javax.annotation.Resource;
import java.util.Map;

/**
 * @Author: lilingyan
 */
@Api(value = "附件依属" , description = "附件与新闻的关系")
@RestController
@RequestMapping(value = "/news/attachments")
public class NewsAttachmentsController {

    @Resource(name = "NewsAttachmentsServieImpl")
    private INewsAttachmentsService newsAttachmentsService;

    @ApiOperation(value = "按新闻查询附件" , notes = "查询新闻所有附件(newId=XXX)")
    @PostMapping("/find")
    @ResponseBody
    public ResponseObj find(@RequestBody RequestPageObj<Map<String,Object>> requestPageObj) throws Exception{
        ResponseObj responseObj = newsAttachmentsService.find(requestPageObj);
        return responseObj;
    }

    @ApiIgnore
    @ApiOperation(value = "按按附件id删除关系" , notes = "attachmentId=XXX")
    @DeleteMapping
    @ResponseBody
    public void deleteByMap(@RequestBody Map<String, Object> newsAttachments) throws Exception{
        newsAttachmentsService.deleteByMap(newsAttachments);
    }

}
